<?php require_once ('header.php'); ?>
<?php 
	if (!isset($_GET['id']) || $_GET['id']==NULL )
	{
		header ('Location:student_stat.php');
	}
	if (isset($_GET['sub']))
	{	$subject = $_GET['sub']; }
	//GET INFO ABOUT THE STUDENT REQUESTED
	$stud_id=$_GET['id'];
	$sql_get_info="SELECT * FROM student WHERE stud_no='$stud_id'";
	$get_info=mysql_query($sql_get_info);
	$info=mysql_fetch_assoc($get_info);
	$name=$info['stud_name']; $sem=$info['stud_sem']; $course=$info['stud_course'];$class=$info['class'];
	$stud_id=strtoupper($stud_id);
?>
<style type="text/css">
<!--
.style1 {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 11px;
}
.style4 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; color: #000000; }
.style5 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; color: #0000FF; }
.style6 {
	font-size: 11px;
	font-weight: bold;
	font-family: Verdana, Arial, Helvetica, sans-serif;
}
.style7 {color: #000000}
-->
</style>

<table width="780" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><p class="style1">&nbsp;</p>
      <table width="680" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td colspan="3" bgcolor="#333333" class="style1"><div align="center"><strong>STUDENT INFO  </strong></div></td>
        </tr>
        <tr>
          <td class="style1">&nbsp;</td>
          <td class="style1">&nbsp;</td>
          <td class="style1">&nbsp;</td>
        </tr>
        <tr>
          <td width="231" class="style4">Student Name </td>
          <td width="10" class="style4">:</td>
          <td width="442" class="style1"><span class="style7"><?php echo $name; ?></span></td>
        </tr>
        <tr>
          <td class="style4">Student Number </td>
          <td class="style4">:</td>
          <td class="style1"><span class="style7"><?php echo $stud_id; ?></span></td>
        </tr>
        <tr>
          <td class="style4">Class</td>
          <td class="style4">:</td>
          <td class="style1"><span class="style7"><?php echo "{$course} {$sem}{$class}"; ?></span></td>
        </tr>
        <tr>
          <td colspan="3" class="style1">&nbsp;</td>
        </tr>
      </table>
	  <table width="680" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td colspan="2" bgcolor="#333333"><div align="center" class="style6">SUBJECT LIST </div></td>
        </tr>
        <tr>
		  <?php 
		  	//GET SUBJECT CURRENTLY REGISTERED TO THIS STUDENT
			$sql_get_subject="SELECT * FROM marks WHERE stud_no='".$stud_id."' GROUP BY mark_subject";
			$get_subjects=mysql_query($sql_get_subject);
			$get_subject=mysql_query($sql_get_subject);
			$rows = mysql_num_rows($get_subjects);
		?>
          <td width="340"><center>
		  <?php if ($rows==1 || $rows > 1)
				{
				while ($sub=mysql_fetch_assoc($get_subject)) {
		  							echo "<a href=\"stat_detail.php?id={$stud_id}&&sub={$sub['subject']}\">{$sub['subject']}</a>&nbsp;&nbsp;"; 
							    } 
				}
				else 
				{
					echo "<br><font color=\"red\">No stats yet for this student</font>"; 
				}?> 
		</center></td> </center></td>
        </tr>
      </table>
	  <?php
	  	if (isset($_GET['sub'])) { ?><br>
		<?php 
			//GET INFORMATION/STAT OF EVERY QUIZZES TAKEN BY STUDENT FROM MARKS TABLE
			$sql_get_mark="SELECT * FROM mark WHERE stud_id='$stud_id' AND course='$course' AND sem='$sem' AND class='$class' AND subject='$subject' ORDER BY quiz_num 			
							ASC";
			$get_mark=mysql_query($sql_get_mark);
			$row=mysql_num_rows($get_mark);
			if ($row < 1 )
				{ $string="STUDENT DID NOT TAKE ANY QUIZ YET"; }
			else 
				{ $string=""; }
		?>
	  <table width="680" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td bgcolor="#333333"><div align="center" class="style6">QUIZ MARKS FOR <?php echo $subject; ?></div></td>
        </tr>
      </table>
	  <br>  
	  <?php 
	  	while ($mark=mysql_fetch_assoc($get_mark)) { 
	  ?> 
	  <table width="203" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td width="86" bgcolor="#FFFFFF" class="style4">QUIZ <?php echo $mark['quiz_num']; ?></td>
          <td width="10" bgcolor="#FFFFFF" class="style4">:</td>
          <td width="107" bgcolor="#666666" class="style5"><center><?php echo $mark['marks']; ?></center></td>
        </tr>
      </table>  
    <?php } }?>
    <p align="center" class="style1"> [ <a href="student_stat.php">Back to student statistic's page</a> ] </p></td>
  </tr>
</table>
<?php require_once ('footer.php'); ?>